package main

func shuffle(nums []int, n int) []int {
	tran := func(j int) int {
		if j < n {
			return j * 2
		} else {
			return j*2 - n*2 + 1
		}
	}

	if len(nums) <= 2 {
		return nums
	}

	for i := 0; i < len(nums); i++ {
		j := i
		for nums[i] > 0 {
			j = tran(j)
			nums[i], nums[j] = nums[j], -nums[i]
		}
	}

	for i := 0; i < len(nums); i++ {
		if nums[i] < 0 {
			nums[i] = -nums[i]
		}
	}

	return nums
}

